<?php

use backend\models\MallMaterial;
use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\MallMaterialSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '素材列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="mall-material-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a('添加', ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

//            'id',
            [
                'attribute' => 'id',
                'headerOptions' => ['width' => 30]
            ],
            [
                'label' => '一级分类',
                'attribute' => 'pid',
                'enableSorting' => false,
                'value' => 'EnuMenu',
//                'filter' => var_dump(CmfMaskMaterial::getMenu()),
                'filter' => MallMaterial::getMenu(),
            ],
//            'mid',
            [
                'label' => '二级分类',
                'attribute' => 'cmfMaterialMenu.title',
                'headerOptions' => ['width' => 10],
                'enableSorting' => false,
            ],
//            'title',
//            [
//                'attribute' => 'title',
//                'enableSorting' => false,
//            ],
//            'style',
            [
                'attribute' => 'style',
                'enableSorting' => false,
                'value' => 'Style',
                'filter' => MallMaterial::attributeValue()['style']
            ],
            //'words',
            //'img_url:ntext',
            //'video_url:ntext',
            'down_count',
            'sort',
            //'update_time:datetime',
            //'create_time:datetime',
//            [
//                'attribute' => 'create_time',
//                'value' => function($model) {
//                    return date("Y-m-d",$model->create_time);
//                }
//            ],
//            'status',
            [
                'attribute' => 'status',
                'enableSorting' => false,
                'value' => 'Status',
                'filter' => MallMaterial::attributeValue()['status']
            ],

            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
</div>
